﻿using System;

namespace diantou.web.management
{
    /// <summary>
    /// 编辑教程
    /// </summary>
    [fastCSharp.code.cSharp.webView(IsPage = false, IsPool = true)]
    partial class tutorialEdit : permissionView<tutorialEdit>
    {
        /// <summary>
        /// 教程
        /// </summary>
        [fastCSharp.emit.webView.clearMember]
        private diantou.dataAccess.tutorial tutorial;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="tutorialId"></param>
        /// <returns></returns>
        private bool loadView(int tutorialId)
        {
            if ((currentUser.Permission & dataModel.user.permission.TutorialEditor) != 0)
            {
                if (tutorialId == 0)
                {
                    tutorial = diantou.dataAccess.tutorial.NullTutorial;
                }
                else
                {
                    if ((tutorial = diantou.dataAccess.clientCache.Tutorial[tutorialId]) != null)
                    {
                        if (currentUser.Permission != dataModel.user.permission.Admin && tutorial.UserId != currentUser.Id) tutorial = null;
                    }
                }
                if (tutorial != null) return true;
            }
            AjaxResponse(new fastCSharp.code.cSharp.webView.errorPath { ErrorPath = currentUser.Path.NewFocus });
            return false;
        }
    }
}
